home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Talking Clock Pro™ 2.0.1 / Talking Clock Pro Source / Extension / Source / notify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-03  |  1.4 KB  |  58 lines  |  [TEXT/CWIE]

  1. /*
  2.  * Notify.c
  3.  */
  4.  
  5. #include <Types.h>
  6.  
  7. #include "notify.h"
  8. #include "str.h"
  9.  
  10. /*
  11.  * We use ONE block of memory containing the following:
  12.  *
  13.  * Response procedure (14 bytes)
  14.  *    this procedure removes the NMRec and disposes the memory
  15.  * Pointer to NMRec (not really needed since the rec is in the block...)
  16.  * String to show in the notification alert
  17.  * Notification record (NMRec)
  18.  *
  19.  * This is so we can put up the notification (in the system heap) and then
  20.  * quit the application and still leave no memory undisposed when the
  21.  * notification is answered by the user
  22.  */
  23.  
  24. #include <Memory.h>
  25. #include <Notification.h>
  26.  
  27. #define LEN 14
  28.  
  29. unsigned short Dummy [ ] = { 0x2f08 , 0x2068 , 0x000e , 0xa05f , 0x205f , 0xa01f , 0x4e75 } ;
  30. #if 0
  31. static void
  32. Dummy ( void ) {
  33.     asm {
  34.         move.l    a0,-(a7)
  35.         move.l    LEN(a0),a0
  36.         dc.w        0xA05F        ; _NMRemove
  37.         move.l    (a7)+,a0
  38.         dc.w        0xa01f        ; _DisposPtr
  39.     }
  40. }
  41. #endif
  42.  
  43.  
  44. void
  45. NotifyStr ( unsigned char * str ) {
  46.  
  47. char * ptr = NewPtrSysClear ( 265 + LEN + sizeof ( void * ) + sizeof ( NMRec ) ) ;
  48. NMRecPtr recPtr = ( NMRecPtr ) ( ptr + 256 + LEN + sizeof ( void * ) ) ;
  49.  
  50.     BlockMove ( & recPtr , ptr + LEN , sizeof ( void * ) ) ;
  51.     BlockMove ( Dummy , ptr , LEN ) ; /* Yeah, really portable for sure --- NOT! */
  52.     recPtr -> qType = nmType ;
  53.     recPtr -> nmStr = ( unsigned char * ) ptr + LEN + sizeof ( void * ) ;
  54.     recPtr -> nmResp = ( void * ) ptr ;
  55.     CopyPString ( str , recPtr -> nmStr ) ;
  56.     ( void ) NMInstall ( recPtr ) ;
  57. }
  58.